import React from 'react';
import { connect } from 'dva';
import App from '../components/App/App';

const IndexPage = ({ app, children, dispatch }) => {
  const handleClike = () => {
    dispatch({
      type: 'app/change',
    });
  };

  const handleMenuItemClick = ({ item, key, keyPath }) => {
    dispatch({
      type: 'app/handleMenuItemClick',
      payload: keyPath,
    });
  };

  return (
    <App app={app} onClick={handleClike} content={children} handleMenuItemClick={handleMenuItemClick} />
  );
};

export default connect(({ app }) => ({
  app,
}))(IndexPage);
